<template>
	<scroll-view scroll-y class="layout">
		<UserInfo ref="userChild" name="测试子组件"></UserInfo>
		<!-- <button @click="getWifi">获取Wi-Fi1</button> -->
		<button @click="changeChildCount">change count</button>
		<button type="default" @click="handleApi">请求API</button>
		<button @click="routeToOrder">去order页面</button>
		<view>
			token: {{ token }}
		</view>
		<view>
			openid: {{ openid }}
		</view>
		
		<!-- <image class="logo" src="/static/logo.png"></image> -->
		<view class="text-area">
			<text class="title">{{title}}</text>
			
		</view>
		
	</scroll-view>
</template>


<script setup>
	import api from '@/api/app.js'
	import useAppStore from '@/store/app.js'
	
	const appStore = useAppStore()
	const title = ref('涤涤卫 v1.0.0')
	const userChild = ref(null)
	const token = ref(appStore.token)
	const openid = ref(appStore.openid)
	
	function handleApi() {
		api.test({a:1, b:2}).then(res=> {
			
		}).catch(err => {
			console.log(err)
		})
	}
	
	const changeChildCount = function() {
		userChild.value.updateCount()
	}

	function routeToOrder() {
		uni.navigateTo({
			url: '/pages/order/order'
		})
	}
	
	function getWifi() {
		// #ifdef MP-WEIXIN
		console.log('开始获取Wi-Fi')
		wx.startWifi({
			success(res) {
				console.log(res)
			},
			fail(res) {
				console.log('失败了', res)
			}
		})
		// #endif
	}
	
	// watch(title, (newValue, oldValue) => {
	// 	console.log(newValue, oldValue)
	// })

	onMounted(() => {
		console.log('onMounted')
	})

	onReady(() => {
		console.log('onReady')
	})

	onShow(() => {
		console.log('onShow')
	})
</script>

<style lang="scss">
	.layout {

		.title {
			color: red;
		}
	}
</style>